package com.cfpl.dealer_service.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cfpl.dealer_service.service.DealerService;
import com.cfpl.project_common.enums.CodeEnum;
import com.cfpl.project_common.exception.BusException;
import com.cfpl.project_common.pojo.Dealer;
import com.cfpl.dealer_service.mapper.DealerMapper;
import com.cfpl.project_common.util.RegexUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Date;

/**
* @author 14720
* @description 针对表【dealer】的数据库操作Service实现
* @createDate 2023-11-10 14:52:51
*/
@Service
public class DealerServiceImpl extends ServiceImpl<DealerMapper, Dealer>
    implements DealerService {

    @Autowired
    private DealerMapper dealerMapper;



    @Override
    public void addDealerInformation(Dealer dealer) {
        if (!RegexUtils.isPhoneValid(dealer.getPhone())  || !RegexUtils.isEmailValid(dealer.getEmail())){
            throw new BusException(CodeEnum.PARAMETER_ERROR);
        }
        dealer.setJoinTime(new Date().getTime());
        dealerMapper.insert(dealer);
    }
}




